<!doctype html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录</title>
  <link rel="stylesheet" type="text/css" href="/dist/css/styles.css">

</head>
<body>
<div class="htmleaf-container">
  <div class="wrapper">
    <div class="container">
      <h1>Welcome</h1>

      <form id="dataForm" method="post" onkeydown="keyLogin();">
        <input  type="text" id="username" placeholder="请输入用户名">
        <input type="password" id="password"  placeholder="请输入密码">

        <div><input type="text"  name="code"  id="code" placeholder="请输入验证码">
          <img id="vcode" src="/lmgame/user/getImage" alt="验证码" align="bottom" style="cursor:pointer;" title="看不清可单击图片刷新" onclick="this.src='/lmgame/user/getImage?d='+Math.random();" />
        </div>

        <button style="width: 119px" type="button"  onclick="submitForm()" id="login-button">登陆</button>&nbsp;&nbsp;<button style="width: 119px" type="button"><a style="color: #53e3a6;text-decoration: none;" href="register.html"> 注册 </a></button>
      </form>
    </div>

    <ul class="bg-bubbles">
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>
  </div>
</div>

<!-- jQuery 3 -->
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="/plugins/iCheck/icheck.min.js"></script>
<script src="/plugins/iCheck/icheck.min.js"></script>
<script src="/dist/js/divfloat.js"></script>
<script src="/dist/js/store.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' /* optional */
        });
    });
    function  submitForm() {
        var username = $("#username").val();
        if(username == ''|| username == null){
            divfloat("用户名不能为空",210,30);
            return;
        }
        var password = $("#password").val();
        if(password == ''|| password == null){
            divfloat("密码不能为空",210,30);
            return;
        }
        var code = $("#code").val();
        if(code == ''|| code == null){
            divfloat("验证码不能为空",210,30);
            return;
        }
        var url="/lmgame/user/login";
        $.ajax({
            type : 'POST',
            url : url,
            data : {
                "username":username,
                "password":password,
                "code":code
            },
            dataType : "json",
            success: function(data) {
                if(data.code!=0){
                    $("#vcode").attr("src","/lmgame/user/getImage?d="+Math.random());
                    divfloat(data.msg,210,30);
                    return;
                }
                store.set("userType",2);
                window.location.href = "/index2.html";
            },
            error:function (data) {

            }
        });
    }


    function keyLogin(){
        if (event.keyCode==13){
            submitForm();
        }
    }

</script>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#000000">
  <h1>渠道后台登陆</h1>
</div>
</body>
</html>